package cn.caplike.demo.repository.design.pattern.observer;

import java.util.ArrayList;
import java.util.List;
import java.util.Vector;

/**
 * @author LiKe
 * @date 2019-08-13 08:50
 */
public class ConcreteWatched implements Watched {
    private final Vector<Watcher> list = new Vector<>(); // 存放具体的观察者

    @Override
    public void addWatcher(Watcher watcher) { list.add(watcher); }
    @Override
    public void removeWatcher(Watcher watcher) { list.remove(watcher); }

    @Override
    public void notifyWatchers(String str) {
        for (Watcher watcher : list) watcher.update(str);
    }
}
